<?php

namespace app\api\controller\store;

use app\models\shop\MerchantAdmin;
use app\models\store\StoreCategory;
use app\Request;

class CategoryController
{
    public function category(Request $request)
    {
        $mer_id = trim(ltrim($request->header('Mer-id')));
        $cateogry = StoreCategory::with('children')
            ->where('is_show', 1)
            ->where('mer_id',$mer_id)
            ->order('sort desc,id desc')
            ->where('pid', 0)
            ->select();
        return app('json')->success($cateogry->hidden(['add_time', 'is_show', 'sort', 'children.sort', 'children.add_time', 'children.pid', 'children.is_show'])->toArray());
    }

    /**
     * 新增获取装修分类列表
     */
    public function get_decoration_cate(Request $request){
        $mer_id    = trim(ltrim($request->header('Mer-id')));
        $cate_info = MerchantAdmin::get(['id'=>$mer_id]);
        $back['cate_id'] = $cate_info['cate_id'];
        return app('json')->success($back);
    }

    /**
     * 新增获取装修分类列表
     */
    public function get_decoration_color(Request $request){
        $mer_id    = trim(ltrim($request->header('Mer-id')));
        $cate_info = MerchantAdmin::get(['id'=>$mer_id]);
        $back['color_id'] = $cate_info['color_id'];
        return app('json')->success($back);
    }

}